// run : $exec < input
#include <iostream>

typedef long long value_type;

int const maxn = 101;
value_type da[maxn], ans[maxn], coe[maxn];
int n;
value_type p, b;

value_type gcd(value_type a, value_type b)
{
	return (!b) ? a : gcd(b, a % b);
}

value_type extended_gcd(value_type a, value_type b, value_type & x, value_type & y)
	// return value is gcd(a, b)
{
	if (!b) { x = 1; y = 0; return a; }
	else {
		value_type e_gcd = extended_gcd(b, a % b, y, x);
		y -= x * (a/b);
		return e_gcd;
	}
}

value_type umsole(value_type a, value_type b, value_type p)
	// univariate_modular_system_of_linear_equation
{
	// a*x  is congruent to  b  modulo  p
	// => a*x + p*(-y) = b
	value_type x, y, b0 = extended_gcd(a, p, x, y);
	value_type m = p / b0;
	return ((x * (b / b0)) % m + m) % m;
}

void nmsole(value_type n, value_type b, value_type p)
{
	if (n == 1) {
		ans[0] = umsole(coe[0], b, p);
	} else
	if (n > 1) {
		// Cn*Xn +  Cn+1*Xn+1 = gcd(Cn, Cn+1) * Y
		// combine Cn and Cn+1 to Y
		value_type c1 = coe[n-2], c2 = coe[n-1];
		coe[n-2] = gcd(c1, c2);
		nmsole(n-1, b, p);
		value_type m = ans[n-2];
		extended_gcd(c1, c2, ans[n-2], ans[n-1]);
		ans[n-2] *= m; ans[n-1] *= m;
	}
}

int main()
{
	std::cin >> n >> p >> b;
	value_type gcd_coe = p;
	bool exist_solution = true;
	for (int i = 0; i < n; i++) {
		std::cin >> da[i];
		coe[i] = gcd(da[i], p);
		gcd_coe = gcd(gcd_coe, coe[i]);
	}
	if (b % gcd_coe) exist_solution = false;
	else {
		nmsole(n, b, p);
		for (int i = 0; i < n; i++)
			ans[i] = umsole(da[i], gcd(da[i], p) * ans[i], p);
	}

	if (exist_solution) {
		std::cout << "YES\n";
		std::cout << ans[0];
		for (int i = 1; i < n; i++) std::cout << ' ' << ans[i];
		std::cout << '\n';
	} else
		std::cout << "NO\n";
}

